//
//  guideViewController.m
//  HuiWenMovie
//
//  Created by niceDay on 15/7/28.
//  Copyright (c) 2015年 computer. All rights reserved.
//

#import "guideViewController.h"
#import "launchViewController.h"
#import "common.h"

@interface guideViewController ()

@end

@implementation guideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self _createSubviews];
}


- (void)_createSubviews{
    _scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    _button = [[UIButton alloc] initWithFrame:CGRectMake(Kwidth*4.3, Kheight - 150, Kwidth*0.4, 50)];
    
    [_button setTitle:@"开始" forState:UIControlStateNormal];
    [_button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    _scrollView.delegate = self;
    _scrollView.pagingEnabled = YES;
    _scrollView.contentSize = CGSizeMake(Kwidth*5, Kheight);
    for (int i = 0; i <5; i++) {
        NSString *guideName = [NSString stringWithFormat:@"guide%d@2x.png",i+1];
        NSString *guideProgressName = [NSString stringWithFormat:@"guideProgress%d@2x.png",i+1];
        UIImageView *guideView = [[UIImageView alloc] initWithFrame:CGRectMake(i*Kwidth, 0, Kwidth, Kheight)];
        guideView.image = [UIImage imageNamed:guideName];
        
        UIImageView *guideProgressView = [[UIImageView alloc] initWithFrame:CGRectMake(i*Kwidth+Kwidth*0.3, Kheight - 60, Kwidth*0.4, 30)];
        guideProgressView.image = [UIImage imageNamed:guideProgressName];
        
        [_scrollView addSubview:guideView];
        [_scrollView addSubview:guideProgressView];
    }
    [_button addTarget:self action:@selector(btnAction) forControlEvents:UIControlEventTouchUpInside];
    [_scrollView addSubview:_button];
    [self.view addSubview:_scrollView];
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    NSInteger index = scrollView.contentOffset.x/Kwidth;
    if (index == 4) {
        _button.hidden = NO;
    }
    else{
        _button.hidden = YES;
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



- (void)btnAction{
    launchViewController *vc = [[launchViewController alloc] init];
    self.view.window.rootViewController = vc;
}
@end
